<?php
/**
 * 公告相关的service实现
 * @文件名称: AnnouncementService.php
 * @author: jawei
 * @Email: gaozhiwei@etcp.cn
 * @Date: 2017-06-06
 * @Copyright: 2017 悦畅科技有限公司. All rights reserved.
 * 注意：本内容仅限于悦畅科技有限公司内部传阅，禁止外泄以及用于其他的商业目的
 */
namespace app\modules\common\services\common;

use app\base\BaseService;
use app\modules\common\models\common\AnnouncementModel;

class AnnouncementService extends BaseService {
    /**
     * 获取公告list服务
     * @param $params
     * @param $offet
     * @param $limit
     * @param array $orderBy
     * @param array $field
     * @return array
     */
    static public function getShowList($params, $offet, $limit, $orderBy=[], $field=['*']) {
        $dataList = AnnouncementModel::getList($params, $offet, $limit, $orderBy, $field);
        if(!empty($dataList)) {
            return BaseService::returnOkData($dataList);
        }
        return BaseService::returnOkData([]);
    }
    /**
     *获取数据条数
     * @param $params
     * @param array $field
     * @return array
     */
    static public function getTotalLine($params, $field=['announcement_id']) {
        $totalLine = AnnouncementModel::getTotalLine($params, $field);
        return BaseService::returnOkData($totalLine);
    }
    /**
     *获取公告想去数据
     * @param $id
     * @return array
     */
    static public function getInfoById($id, $field=['*']) {
        $id = (int)$id;
        if($id) {
            $dataInfo = AnnouncementModel::findInfoById($id, $field);
            if(empty($dataInfo)) {
                return BaseService::returnErrData([], 5001945, "请求数据不存在");
            }
            return BaseService::returnOkData($dataInfo);
        }
        return BaseService::returnErrData([], 5001939, "请求参数异常");
    }
}
